package com.feng.zhihao.apigeteway.config.spring;

import java.util.Arrays;

import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;

@Configuration
// 扫描 com.feng.zhihao.apigeteway.web 包下的servlet容器注解
@ServletComponentScan(basePackages = { "com.feng.zhihao.apigeteway.web" })
public class WEB {
	@Bean("jsonConverter")
	public FastJsonHttpMessageConverter4 getFastJsonHttpMessageConverter() {
		FastJsonHttpMessageConverter4 converter4 = new FastJsonHttpMessageConverter4();
		converter4.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));
		FastJsonConfig fastJsonConfig = new FastJsonConfig();
		fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);
		converter4.setFastJsonConfig(fastJsonConfig);
		return converter4;
	}
}
